﻿using System;
using System.Diagnostics;
using System.Security.Permissions;

using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UITesting.WinControls;
using TechTalk.SpecFlow;

using CodeStream.Testing.WebAutomation.InternetExplorer;

namespace CodeStream.Testing.WebAutomation.SpecFlow
{
    [Binding]    
    public class InternetExplorerBinding
    {
        [BeforeFeature("browser.ie")]
        public static void BeforeFeature_Browser_IE()
        {
            FeatureContext.Current.Add("Browser", new InternetExplorerInstance());
        }

        [BeforeFeature("browser.ie.noscript")]
        public static void BeforeFeature_Browser_IE_NoScript()
        {
            FeatureContext.Current.Add("Browser", new InternetExplorerInstance(false));
        }

        [AfterFeature("browser.ie")]
        [AfterFeature("browser.ie.noscript")]
        public static void AfterFeature_Browser_IE()
        {
            InternetExplorerInstance browser = FeatureContext.Current.Get<InternetExplorerInstance>("Browser");
            if (browser != null)
            {
                browser.Dispose();
                FeatureContext.Current.Remove("Browser");
            }
        }
    }
}
